<?php 

// 控制基类  所有控制器都将继承基类
class Controller extends Smarty
{

	public function __construct()
	{
		// 配置smarty
        $this->setTemplateDir('./views')
               ->setCompileDir('./runtime/views_c')
               ->setConfigDir('./configs')
               ->setCacheDir('./runtime/caches');
        $this->left_delimiter = LEFT_D;
        $this->right_delimiter = RIGHT_D;
        $this->caching = CACHING;
        $this->cache_lifetime = CACHE_LIFETIME;
	}
	// 当调用不存在的方法的处理 :
	public function __call($fun,$params)
	{
        header("HTTP/1.0 404 not found");
        echo '<h1>404 NOT FOUND(基类  不存在的方法)</h1>';
        exit;
	}
  
    // 跳转重定向
    public function redirect($message,$url = null)
    {
    	echo "<script>alert('{$message}')</script>";
    	if(empty($url)) {
            echo "<script>history.back()</script>";
    	} else {
            echo "<script>location.href='{$url}'</script>";
    	}
    }

}









 ?>